package com.atguigu.boot.controller;

import com.atguigu.boot.bean.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : leimingchao
 * @date Date : 2021年11月22日 12:51
 */
@RestController
public class HelloController {

    @Value(value = "${person.name:李四}")
    private String name;

    @Autowired
    private Person person;

    /**
     * @Value：
     *      不仅可以从配置文件中取值，还可以从环境变量中取值
     */
    @Value(value = "${MAVEN_HOME}")
    private String msg;

    @Value(value = "${os.name}")
    private String osName;

    @GetMapping(value = "/")
    public String hello() {
        return person.getClass().toString();
    }

    @GetMapping(value = "/person")
    public Person person() {
        return person;
    }

    @GetMapping(value = "/msg")
    public String getMsg() {
        return msg + "======>" + osName;
    }
}
